<template>
  
<div>
 <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-field label="请输入用户名" v-model="name" /></van-col>
      <van-col span="8"></van-col>
    </van-row>
    <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-field label="请输入密码" v-model="password" /></van-col>
      <van-col span="8"></van-col>
    </van-row>
    <van-row>
      <van-col span="8"></van-col>
      <van-col span="8"><van-button @click="login">点击登录</van-button></van-col>
      <van-col span="8"></van-col>
    </van-row>
</div>
</template>

<script>
import axios from '../../http/axios'
export default {
    data(){
        return{
            name:'',
            password:''
        }
    },


    methods:{
        login(){
            axios('login?name='+this.name+"&password="+this.password,'get').then(res=>{
                console.log(res);
                if(res.code == 200){
                    this.$toast.success("登陆成功")
                    localStorage.setItem("userid",res.userid)
                    localStorage.setItem('token',res.token)
                    localStorage.setItem('vurl',JSON.stringify(res.vurl))
                }else{
                    this.$toast.fail("登陆失败")
                }
            })
        }

    }

}
</script>

<style>

</style>